package com.zengqingfa.examples.mybatisplus;

import com.zengqingfa.examples.mybatisplus.mapper.UserHistoryMapper;
import com.zengqingfa.examples.mybatisplus.mapper.UserMapper;
import com.zengqingfa.examples.mybatisplus.rest.UserController;
import com.zengqingfa.examples.mybatisplus.service.OrderService;
import com.zengqingfa.examples.mybatisplus.service.PersonService;
import com.zengqingfa.examples.mybatisplus.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * @fileName: MyBatisPlusApplication
 * @author: zengqf3
 * @date: 2020-8-1 14:05
 * @description:
 */
@SpringBootApplication
@EnableAspectJAutoProxy
@MapperScan(basePackages = "com.zengqingfa.examples.mybatisplus.mapper")
public class MyBatisPlusApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(MyBatisPlusApplication.class, args);
        UserController controller = context.getBean(UserController.class);
        //子类代理
         //class com.zengqingfa.examples.mybatisplus.rest.UserController$$EnhancerBySpringCGLIB$$8987eb20
        System.out.println(controller.getClass());
        UserMapper userMapper = context.getBean(UserMapper.class);
        UserHistoryMapper userHistoryMapper = context.getBean(UserHistoryMapper.class);
        //jdk动态代理 class com.sun.proxy.$Proxy83
        System.out.println(userMapper.getClass());
        OrderService orderService = context.getBean(OrderService.class);
        orderService.order();
        PersonService personService = context.getBean(PersonService.class);
        personService.order();
    }
}
